package fw;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.ITestResult;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Listeners;

@Listeners({ TestBase.LogListener.class })
public class TestBase {

	private static Logger LOG = LoggerFactory.getLogger(TestBase.class);
	protected ApplicationManager app;

	@BeforeTest
	public void init() {
		/* Create app object */
		app = new ApplicationManager();
		app.init();
	}

	@AfterTest
	public void stopDriver() {
		app.getDriver().quit();
	}

	public static class LogListener implements IInvokedMethodListener {

		@Override
		public void afterInvocation(IInvokedMethod m, ITestResult res) {
			LOG.info("<<< @Test " + m);
		}

		@Override
		public void beforeInvocation(IInvokedMethod m, ITestResult res) {
			LOG.info(">>> @Test " + m);
		}

	}

}
